from world import World
from direct.showbase import DirectObject
from direct.gui.DirectGui import *
from direct.gui.OnscreenText import OnscreenText
from direct.gui.OnscreenImage import OnscreenImage

import direct.directbase.DirectStart
import sys

class About(DirectObject.DirectObject):  
   def __init__(self):
       self.frame = DirectFrame(frameSize=(-0.5, 0.5, -0.5, 0.5), frameColor=(1.0, 1.0, 1.0, 1), pos=(0, 0, 0))
       self.headline = DirectLabel(parent=self.frame, text="About", scale=0.085, frameColor=(0, 0, 0, 0), pos=(0, 0, 0.4))
       
       self.Text = DirectLabel(
                                     parent=self.frame,
                                     text="\nSuicidal Nut Squirrel\n\nCreated for \"COS600 - Animacao e Jogos\" course \nEngenharia de Computacao e Informacao (ECI)\nUniversidade Federal do Rio de Janeiro (UFRJ) | Brazil\nMarch ~ July/2010\n\nAuthors: \nUlysses Vilela, \nRomulo Fernandes, \nLucas Paes",
                                     scale=0.04,
                                     frameColor=(0, 0, 0, 0),
                                     pos=(0, 0, 0.35),
                                     )
       
       self.backButton = DirectButton(parent=self.frame, text="back", command=self.hide, pos=(0, 0, -0.4), scale=0.07)
       self.hide()  
   def show(self): #Function that display the window
       self.frame.show()
   def hide(self): #Function that hide the window
       self.frame.hide()
       
class StartMenu(DirectObject.DirectObject): #Class for main menu
    def __init__(self, cond=1): #Class constructor
        
        self.frame = DirectFrame(frameSize=(-0.5, 0.5, -0.5, 0.5), frameColor=(0.8, 0.8, 0.8, 0), pos=(0, 0, 0))
        self.frame2 = DirectFrame(parent=render2d, image="textures/Suicidal.png", sortOrder=(-1))
        
        self.startButton = DirectButton(parent=self.frame, text="New Game", command=self.doStartGame, pos=(1, 0, -0.5), text_scale=0.08, text_fg=(0, 0, 0, 1), borderWidth=(0.005, 0.005), frameSize=(-0.25, 0.25, -0.03, 0.06), frameColor=(0.8, 0.8, 0.8, 0)) 
        self.aboutButton = DirectButton(parent=self.frame, text="About", command=self.showAbout, pos=(1, 0, -0.6), text_scale=0.08, text_fg=(0, 0, 0, 1), borderWidth=(0.005, 0.005), frameSize=(-0.25, 0.25, -0.03, 0.06), frameColor=(0.8, 0.8, 0.8, 0))
        self.quitButton = DirectButton(parent=self.frame, text="Quit", command=sys.exit, pos=(1, 0, -0.7), text_scale=0.08, text_fg=(0, 0, 0, 1), borderWidth=(0.005, 0.005), frameSize=(-0.25, 0.25, -0.03, 0.06), frameColor=(0.8, 0.8, 0.8, 0))
        
        self.showMenu()
        self.about = About()
        
    def showMenu(self): #Function that show menu
        self.frame.show()
        self.frame2.show()
            
    def hideMenu(self): #Function that hide menu
        self.frame.destroy()
        self.frame2.destroy()
            
    def doStartGame(self): #Function that show graphic settings
        self.hideMenu()
        World()
             
    def showAbout(self): #Function that show credits
        self.about.show()
